package RemoteServer;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;

import CustomerPO.CustomerPO;
import DataBase.DB_Factory;
import Po.BookPO;
import Po.Credits;
import Po.Message;
import Po.Order;
import Po.Promotion;
import Po.RegisterCustomer;
import Po.SimpleBook;
import Po.SimpleCustomer;
import Po.Type;
import RemoteServerInterface.CustomerServerInterface;

public class CustomerServer  extends UnicastRemoteObject implements CustomerServerInterface{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public CustomerServer() throws RemoteException {}

	@Override
	public SimpleCustomer customerLogin(String name, String password) {
		return DB_Factory.getCustomerServerDB().customerLogin(name, password);
	}

	@Override
	public Message registerCustomer(RegisterCustomer customer) {
		return DB_Factory.getCustomerServerDB().registerCustomer(customer);
	}

	@Override
	public Message deleteCustomer(int ID) {
		return DB_Factory.getCustomerServerDB().deleteCustomer(ID);
	}

	@Override
	public ArrayList<SimpleBook> searchBook(String key, Type type) {
		return DB_Factory.getBookServerDB().searchBook(key, type,true);
	}

	@Override
	public String[][] getBookTree() {
		return DB_Factory.getBookServerDB().getBookTree();
	}

	@Override
	public BookPO getBookDetail(String ISBN) {
		return DB_Factory.getBookServerDB().getBookDetail(ISBN);
	}

	@Override
	public Message collectBook(int ID, String ISBN) {
		return DB_Factory.getBookServerDB().collectBook(ID, ISBN);
	}

	@Override
	public ArrayList<Promotion> getCustomerPromotionList(int ID) {
		return DB_Factory.getPromotionServerDB().getCustomerPromotionList(ID);
	}

	@Override
	public ArrayList<SimpleBook> getBookCollection(int ID) {
		return DB_Factory.getBookServerDB().getBookCollection(ID);
	}

	@Override
	public ArrayList<Order> getOrderList(int ID) {
		return DB_Factory.getOrderServerDB().getOrderList(ID);
	}

	@Override
	public Message updateCustomer(CustomerPO c) {
		return DB_Factory.getCustomerServerDB().updateCustomer(c);
	}

	@Override
	public Message saveOrder(Order o) {
		return DB_Factory.getOrderServerDB().update(o);
	}

	@Override
	public Credits getCredits(int id) throws RemoteException {
		return DB_Factory.getPromotionServerDB().getCredits();
	}

	@Override
	public Message deleteCollectBook(int id, String isbn) throws RemoteException {
		return DB_Factory.getBookServerDB().deleteCollectedBook(id,isbn);
	}

}
